<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<?php  $data['leftnav']=2;$this->load->view('admin/header.html',$data)?>
<script type="text/javascript" src="<?php echo base_url()?>common/js/additional-methods.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/validateForm.js"></script>
<script>
   
    $(function () {
        $("#mparentmid").change(function () {
            var selectItem = $(this).find("option[value=" + $(this).val() + "]");
            $("#mlevel").val(selectItem.attr("level"));
            $("#mpath").val(selectItem.attr("mpath"));      
            if ($(this).val() != 0) {
                var topmenuId = selectItem.attr("mpath").split(',')[0];
                $.get('/admin/menu/geturl', { 'topmenuid': topmenuId }, function (data) {
                    var jsonData = $.parseJSON(data);
                    if (data != null) {
                        $("#mctrl").attr('readonly', 'readonly'); $("#mctrl").val(jsonData.mctrl);
                        $("#mact").attr('readonly', 'readonly'); $("#mact").val(jsonData.mact);
                    }
                })
            } else {
                $("#mctrl").removeAttr('readonly'); $("#mctrl").val("");
                $("#mact").removeAttr('readonly'); $("#mact").val("");
                $("#mpath").val(1);
            }
        });
    });
    function Success(data) {
        $.Success(data);
    }
    $(function () {
        $.validate_menu('ajax_form', 1);
    });
</script>
<div id="dcMain">
    <!-- 当前位置 -->
    <div id="urHere">DouPHP 管理中心<b>></b><strong>栏目添加</strong> </div>   <div id="manager" class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
        <h3><a href="<?php echo site_url('admin/menu/menulist')?>" class="actionBtn">返回列表</a>栏目添加</h3>
        <form id="ajax_form"  action="<?php echo site_url('admin/menu/add_menu')?>" method="post">
            <input type="hidden" value="0" name="mchild" />
            <input type="hidden" value="1" name="mlevel" id="mlevel" />
            <input type="hidden" value="1" name="mpath" id="mpath" />
            <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                <tr>
                    <td align="right">上级栏目</td>
                    <td>
                        <select name="mparentmid" id="mparentmid">
                            <option value="0" level="1">顶级栏目</option>
                            <?php foreach($menuList as $menuItem):?>
                            <option value="<?php echo $menuItem->mid;?>" level="<?php echo $menuItem->mlevel+1;?>" mpath="<?php echo $menuItem->mpath;?>"><?php for($i=0;$i<$menuItem->mlevel;$i++){echo('&nbsp;');}?> |-<?php echo $menuItem->mtitle;?></option>
                            <?php endforeach; ?>
                        </select>
                    </td>
                </tr>
                <tr>                    
                    <td width="100" align="right">栏目名称</td>
                    <td>
                        <input type="text" id="mtitle" name="mtitle" size="40" class="inpMain" value="" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">英文名称</td>
                    <td>
                        <input type="text" id="mtitle" name="mentitle" size="40" class="inpMain" value="" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">栏目url设置</td>
                    <td>
                        <input type="text"  name="mctrl" id="mctrl" size="20" class="inpMain" value="" />/<input type="text" id="mact" name="mact" size="20" class="inpMain" value="" />
                    </td>
                </tr>
                <tr>
                    <td align="right">栏目启用</td>
                    <td>
                        <select name="misuse">
                            <option value="1">启用</option>
                            <option value="0">取消</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="submit" class="btn" value="添加" />
                        <input type="button" class="btn" value="返回" onclick="GoBack()" />
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>